﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using HotelManager.ServiceReference1;
using HotelManager.ViewModels;
using SilverlightStudentManager.ViewModels;

namespace HotelManager.ViewModel
{
    public class BacLuongViewModel: ViewModelBase
    {
        private BacLuongClient bacluongclient = new BacLuongClient();
        private BACLUONG newBacLuong = new BACLUONG();
         public BacLuongViewModel()
        {
            //MessageBox.Show("Called");
            this.GetbyAllBacLuong();
        }
        private void GetbyAllBacLuong()
        {
            //MessageBox.Show("Called");
            this.bacluongclient.GetByAllBacLuongCompleted += (s, e) =>
            {
                MessageBox.Show(e.Result[0].MaBacLuong.ToString());
                this.ListBacLuong = e.Result;
                
            };
            this.bacluongclient.GetByAllBacLuongAsync();
        }
        private IEnumerable<BACLUONG> listBacLuong;
        public IEnumerable<BACLUONG> ListBacLuong
        {
            get
            {
                return this.listBacLuong;
            }

            set
            {
                this.listBacLuong = value;
                this.OnPropertyChanged("ListBacLuong");
            }
        }
        // current Bac luong
        private BACLUONG currentBacLuong;
        public BACLUONG CurrentBacLuong
        {
            get
            {
                return this.currentBacLuong;
            }
            set
            {
                this.currentBacLuong = value;
                this.newBacLuong = this.CurrentBacLuong;
                if (this.currentBacLuong == null)
                {
                    this.newBacLuong = new BACLUONG();
                }
                //else this.RefreshToViewErrors();
                this.OnPropertyChanged("CurrentBacLuong");
            }
        }
        private void RefreshToViewErrors()
        {
            //this.MaBacLuong = this.newBacLuong.MaBacLuong;
            //this.TenBacLuong = this.newBacLuong.HoTen;
        }

    }
   
}
